<template>
    <div class="case-doing-container">
      <span class="title">{{caseName}}</span>
      <!--<span class="des">单元：英语视听说社交口语</span>-->
      <span class="cell">时间：{{dateTime}}</span>
      <span class="cell">进度：{{finishedLinkNum}}/{{linkNum}}（{{rate}}%）</span>
      <span class="cell">耗时：{{durationFormate}}</span>
      <div class="button">
        <el-button type="primary" @click="toTaskList" style="width: 219px;">继续训练</el-button>
      </div>
    </div>
</template>

<script>
export default {
  name: 'caseDoingBox',
  props: {
    /**
     * 案例名称
     */
    caseName: String,
    /**
     * 日期
     */
    dateTime: String,
    /**
     * 环节数
     */
    linkNum: Number,
    /**
     * 完成的环节数
     */
    finishedLinkNum: Number,
    /**
     * 时长，单位秒
     */
    duration: Number,
    /**
     * 案例资源id
     */
    resourceCaseId: String
  },
  computed: {
    /**
     * 进度比率
     * @returns {string}
     */
    rate () {
      return (this.finishedLinkNum / this.linkNum).toFixed(2) * 100
    },
    /**
     * 秒格式化为 分钟格式
     * @returns {string}
     */
    durationFormate () {
      return (this.duration / 60).toFixed(2).split('.').join('`')
    }
  },
  methods: {
    toTaskList () {
      this.$router.push({ name: 'taskList', query: { resourceCaseId: this.resourceCaseId } })
    }
  }
}
</script>

<style scoped lang="scss">
.case-doing-container{
  width:478px;
  height:298px;
  background:rgba(255,255,255,1);
  border:8px solid rgba(213,226,242,1);
  border-radius:10px;
  margin-top: 23px;
  margin-bottom: 23px;
  box-sizing: border-box;
  padding: 30px;
  display: flex;
  flex-flow: column nowrap;
  .title{
    margin-bottom: 10px;
    font-size:18px;
    font-family:PingFang SC;
    font-weight:400;
    color:rgba(16,29,55,1);
  }
  .des{
    font-size:14px;
    font-family:PingFang SC;
    font-weight:500;
    color: #D5E2F2;
    line-height: 28px;
  }
  .cell{
    font-size:16px;
    font-family:PingFang SC;
    font-weight:500;
    color:rgba(16,29,55,1);
    line-height: 28px;
  }
  .button{
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 39px;
  }
}
</style>
